< previous page page_372 next page >

Page 372
Report Description
Description that the user sees in the list box.
Report File Name
If this record is for an actual report, than the filename goes here. If it isn't a report, then put spaces here.

This will help you dynamically build the list box data whenever the application is started. The next order of business is to finish the command button code. Listing 13.4 displays the code for the Close and Printer Setup buttons. The Close button is self-explanatory. However, the Printer Setup button calls the Common Dialog control to display the Printer Setup common dialog box for the user to modify. You can see from the code that the only property that can be changed is the number of copies to print. The Crystal Reports property CopiesToPrint is set to this value.
LISTING 13.4. RPTMGR04.TXTADDING THE CLOSE AND THE SETUP CODE FOR THE REPORT MANAGER.

8694cbadb9b1ef7075903f6f95fc1db2.gif
1: Private Sub cmdPrtSetup_Click()
2:     DlgReports.ShowPrinter
3:     rptAddress.CopiesToPrinter = DlgReports.Copies
4: End Sub
5:
6: Private Sub cmdCancel_Click()
7:     Unload Me
8: End Sub

Of course, you can always add code to enable the user to change printers or set other options for the printing of the report.
Now, let's add the code for the Continue button next, so that you can try out the application. This routine first checks to see if a report is selected before continuing; if no report is selected, an error message is displayed to the user. If a report is selected, it checks to see if the report exists; it obtains the report name from the list box and sets the Crystal Reports properties and finally runs the report. Add the code in Listing 13.5 and try executing the application, selecting a report and displaying it.
LISTING 13.5. RPTMGR05.TXTTHE MAIN ROUTINE IN THE REPORT MANAGER THAT PRINTS THE REPORT.

8694cbadb9b1ef7075903f6f95fc1db2.gif
 1: Private Sub cmdReport_Click()
 2:     If lstReportName.ListIndex = -1 Then
 3:         MsgBox You must first select a Report., vbCritical, _

 
< previous page page_372 next page >

If you like this book, buy it!